package file.day9_18.day02;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class Test02CopyFileTop {
    public static void main(String[] args) throws IOException {
        FileInputStream fis;
        FileOutputStream fos;
        byte[] data = new byte[1024*10];
        File file = new File(".");
        File[] files = file.listFiles(f->f.isFile());
        for(File file1 : files){
            String name = file1.getName();
            int index = name.indexOf(".");
            String before = name.substring(0,index);
            String after = name.substring(index);
            String newName = before + "_cp" + after;
            fis = new FileInputStream(name);
            fis.read(data);
            fos = new FileOutputStream(newName);
            fos.write(data);
            System.out.println("复制完成");
            fis.close();
            fos.close();
        }
    }
}
